<?
	layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">分库分表设置</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>系统管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">分库分表设置</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">

		<!-- 管理界面 start -->
		<div class="row">
			<div class="col-lg-12">
				<div class="note note-danger">
					<h3 class="box-heading">Tips</h3>
					<p>
		           	1、分库分表设置是大数据量和高并发项目性能优化的策略之一，目前支持分库分表；需要配置数据源信息和分库分表策略；
		            </p>
		            <p>
		           	2、数据源配置目前支持MYSQL数据库，如不同机器之间的读写分离功能，需配置数据库数据同步的功能；
		            </p>
		            <p>
		           	3、分库分表和数据源配置功能需在建立知识体系结构之前构建完毕，禁止在建立知识结构后再调整，出现问题不予以维护和处理；
		            </p>
		            <p>
		           	4、数据源配置和分库分表策略变更后都需要进行数据发布操作。
		            </p>
				</div>
			</div>
		</div>
		<div class="row mbl">
           <div class="col-lg-6">
				<h4># 数据源配置 <button class="btn btn btn-grey" onclick="toShardingRepositoryDataSource('0')">+</button></h4>
			</div>
			<div class="col-lg-6">
				<div class="tb-group-actions pull-right">
           			<button class="btn btn btn-success" onclick="toDatabase()">数据源管理</button>
               </div>
			</div>
		</div>
		<div class="row" style="margin-bottom: 10px;">
			<div class="col-lg-12">
				<span style="font-size: 20px;">数据库：<button class="btn btn-sm btn-danger" onclick="">全部</button></span>
				<span style="font-size: 20px;" id="databaseText">
				</span>
			</div>
		</div>
		<div class="row">
            <div class="col-lg-4">
                <div class="panel">
                    <div class="panel-heading clearfix">
                    		<span class="mts pull-left">dal_master_0</span>
                    		<div class="toolbars">
                             <div class="input-icon right">
                             	<button class="btn btn-sm btn-grey" onclick="">编辑</button>
                             	<button class="btn btn-sm btn-danger" onclick="">删除</button>
                             </div>
                         </div>
                    </div>
                    <div class="panel-body">
                    <p style="font-size: 15px;">
                    		type：<span class="badge badge-danger">Master</span>
                    		<span class="badge badge-danger">默认数据源</span>
                    </p>
                    <p style="font-size: 15px;">
                    		driverClassName：com.mysql.jdbc.Driver
                    </p>
                    <p style="font-size: 15px; test-overflow:ellipsis;">
                    		url：<button type="button" class="btn btn-sm btn-default">查看URL</button>
                    </p>
                    	<p style="font-size: 15px;">
                    		username：root
                    </p>
                    <p style="font-size: 15px;">
                    		password：****
                    </p>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="panel">
                    <div class="panel-heading clearfix"><span class="mts pull-left">dal_master_0_slave_0</span>
                    		<div class="toolbars">
                             <div class="input-icon right">
                             	<button class="btn btn-sm btn-grey" onclick="">编辑</button>
                             	<button class="btn btn-sm btn-danger" onclick="">删除</button>
                             </div>
                         </div>
                    </div>
                    <div class="panel-body">
                    <p style="font-size: 15px;">
                    		type：<span class="badge badge-danger">Slave</span>
                    </p>
                    <p style="font-size: 15px;">
                    		driverClassName：com.mysql.jdbc.Driver
                    </p>
                    <p style="font-size: 15px; test-overflow:ellipsis;">
                    		url：<button type="button" class="btn btn-sm btn-default">查看URL</button>
                    </p>
                    	<p style="font-size: 15px;">
                    		username：root
                    </p>
                    <p style="font-size: 15px;">
                    		password：****
                    </p>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="panel">
                    <div class="panel-heading clearfix"><span class="mts pull-left">dal_master_0_slave_1</span>
                    		<div class="toolbars">
                             <div class="input-icon right">
                             	<button class="btn btn-sm btn-grey" onclick="">编辑</button>
                             	<button class="btn btn-sm btn-danger" onclick="">删除</button>
                             </div>
                         </div>
                    </div>
                    <div class="panel-body">
                    <p style="font-size: 15px;">
                    		type：<span class="badge badge-danger">Slave</span>
                    </p>
                    <p style="font-size: 15px;">
                    		driverClassName：com.mysql.jdbc.Driver
                    </p>
                    <p style="font-size: 15px; test-overflow:ellipsis;">
                    		url：<button type="button" class="btn btn-sm btn-default">查看URL</button>
                    </p>
                    	<p style="font-size: 15px;">
                    		username：root
                    </p>
                    <p style="font-size: 15px;">
                    		password：****
                    </p>
                    </div>
                </div>
            </div>
            
        </div>
        
        <div class="row mbl">
           <div class="col-lg-12">
				<h4># 策略配置
			</div>
		</div>
		
		<div class="row">
           <div class="col-lg-4">
                <div class="panel">
                    <div class="panel-heading clearfix"><span class="mts pull-left">分库策略</span>
                    		<div class="toolbars">
                             <div class="input-icon right">
                             	<button class="btn btn-sm btn-grey" onclick="">编辑</button>
                             	<button class="btn btn-sm btn-danger" onclick="">删除</button>
                             </div>
                         </div>
                    </div>
                    <div class="panel-body">
                    <p style="font-size: 15px;">
                    		状态：<span class="badge badge-danger">启用</span>
                    </p>
                    <p style="font-size: 15px;">
                    		算法：
                    </p>
                    <p style="font-size: 15px;">
                    		其他：
                    </p>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="panel">
                    <div class="panel-heading clearfix"><span class="mts pull-left">分片策略</span>
                    		<div class="toolbars">
                             <div class="input-icon right">
                             	<button class="btn btn-sm btn-grey" onclick="">编辑</button>
                             	<button class="btn btn-sm btn-danger" onclick="">删除</button>
                             </div>
                         </div>
                    </div>
                    <div class="panel-body">
                    <p style="font-size: 15px;">
                    		状态：<span class="badge badge-danger">启用</span>
                    </p>
                    <p style="font-size: 15px;">
                    		分片字段：data_id
                    </p>
                    <p style="font-size: 15px;">
                    		其他：
                    </p>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="panel">
                    <div class="panel-heading clearfix"><span class="mts pull-left">读写分离</span>
                    		<div class="toolbars">
                             <div class="input-icon right">
                             	<button class="btn btn-sm btn-grey" onclick="">编辑</button>
                             	<button class="btn btn-sm btn-danger" onclick="">删除</button>
                             </div>
                         </div>
                    </div>
                    <div class="panel-body">
                    <p style="font-size: 15px;">
                    		名称：dal_ms
                    </p>
                    <p style="font-size: 15px;">
                    		主节点：<span class="badge badge-danger">dal_master_0</span>
                    </p>
                    <p style="font-size: 15px;">
                    		从节点：<span class="badge badge-danger">dal_master_0_slave_0</span>
                    		<span class="badge badge-danger">dal_master_0_slave_1</span>
                    </p>
                    </div>
                </div>
            </div>
            
		</div>
		
		
		<!-- 管理界面 end -->
  
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script type="text/javascript">
$(function() {
	getDatabaseAll();
});
function toDatabase() {
	layer.open({
		type : 2,
		area : [ '700px', '600px' ],
		scrollbar : false,
		shadeClose : true,
		fix : false, //不固定
		title : '数据源管理',
		//maxmin : true,  
		skin : 'layui-layer-rim', //加上边框
		btn : [ '关闭' ],
		content : [ "knowledge-edit-sharding-database-list.html", 'no' ],
		yes : function(index, layer) {
			var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			iframeWin.DatabaseList();
		},
		cancel : function(index) {
			getDatabaseAll();
		}
	});
}
//查询全部数据源
function getDatabaseAll(){
	$.ajax({
		type : "post",
		url : "getDatabaseAll.do",
		dataType : "json",
		data:{},
		traditional : true,
		beforeSend : function(XMLHttpRequest) {},
		success:function(data){
			var src='';
			for (i=0;i<data.length ;i++ ){
				src+= '<button class="btn btn-sm btn-danger" style="margin-right: 5px;" onclick="getShardingRepositoryDataSource('+data[i].id+')">'+data[i].nameZh+'</button>';
			}
			$("#databaseText").html(src);
		},
		error:function(){
			alert("编辑失败");
		}

	})
}
var shardingRepositoryDataSourceId;
function getShardingRepositoryDataSourceId() {
	return shardingRepositoryDataSourceId;
}
//配置数据源
function toShardingRepositoryDataSource(repositoryDataSourceId) {
	shardingRepositoryDataSourceId = repositoryDataSourceId
	layer.open({
		type : 2,
		area : [ '700px', '600px' ],
		scrollbar : false,
		shadeClose : true,
		fix : false, //不固定
		title : '配置数据源',
		//maxmin : true,  
		skin : 'layui-layer-rim', //加上边框
		btn : [ '保存','关闭' ],
		content : [ "sharding-repository-data-source.html", 'no' ],
		yes : function(index, layer) {
			var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			iframeWin.DatabaseList();
		},
		cancel : function(index) {
			getDatabaseAll();
		}
	});
}
//查询数据源下表
function getShardingRepositoryDataSource(dataSourceId){
}
</script>